package com.lemon.equipment.domain.vo;

import com.lemon.equipment.enums.BizCodeEnum;
import lombok.Data;

/**
 * 作者：朱骏杰
 * 时间：2024/7/28
 * 描述：
 */

@Data
public class ResultVO<T> {
    private Boolean success;

    private String message;

    private T data;

    private Integer code;

    public static <T> ResultVO<T> success(T data){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setSuccess(true);
        resultVO.setData(data);
        resultVO.setCode(BizCodeEnum.SUCCESS.getCode());
        return resultVO;
    }
    public static <T> ResultVO<T> success(){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setSuccess(true);
        resultVO.setCode(BizCodeEnum.SUCCESS.getCode());
        return resultVO;
    }
    public static <T> ResultVO<T> fail(T data){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setSuccess(false);
        resultVO.setData(data);
        resultVO.setCode(BizCodeEnum.UNKNOWN_ERROR.getCode());
        return resultVO;
    }
    public static <T> ResultVO<T> fail(){
        ResultVO<T> resultVO = new ResultVO<>();
        resultVO.setSuccess(false);
        resultVO.setCode(BizCodeEnum.UNKNOWN_ERROR.getCode());
        return resultVO;
    }

}
